function mask = createUndersampleMask(mask_flag,underSampleMethod,Rfactor,numPE,numFE)
%CREATEUNDERSAMPLEMASK Summary of this function goes here
%   Detailed explanation goes here


switch mask_flag.flag
    case 'Load'
        load(mask_flag.file)
    case 'Create'
        switch underSampleMethod
            case 'Lustig'
                % Pre-allocate arrays
                pdfTemp = zeros(numPE);
                maskTemp = zeros(numPE);
                pdf = zeros(numPE,numFE);
                
                if Rfactor<2
                    polyNom = 2;
                elseif Rfactor<3
                    polyNom = 3;
                elseif Rfactor<4
                    polyNom = 4;
                else
                    polyNom = 12;
                end
                
                pdfTemp= genPDF([1,numPE],polyNom,1/Rfactor,2,0.08,0);
                maskTemp = genSampling(pdfTemp(:),100,1);
                
                mask = repmat(maskTemp',numFE,1);
            case 'Poisson'
                mask = vdPoisMex(numFE,numPE,numFE*2,numPE*2,sqrt(Rfactor),sqrt(Rfactor),16,0,0);
        end
end

end

